Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add backend logic for column filtering #35846

Merged
merged 19 commits into from
Feb 26, 2025
Merged

Add backend logic for column filtering #35846

merged 19 commits into from
Feb 26, 2025

Conversation

biyeun
Copy link
Member

@biyeun biyeun commented Feb 25, 2025

Technical Summary

This PR implements the backend logic for filtering a CaseSearchES query based on the BulkEditColumnFilters associated with a BulkEditSession.

Review commit-by-commit.

  • I tried my best to reorder commits in the most narrative order, making each commit small and bite-sized
  • please don't be intimidated by number of commits or number of lines changed (there are a lot of tests that contribute to the bulk of this PR's size)

While working on this I discovered a few issues with our current model definitions:

  • xpath_query does not support an "ends with" so I replaced it with not(starts-with(...))
  • for improved clarity, I added separate lte (<=) and gte (>=) match types
  • xpath_query does not support <, >, <=, and >= for text, only dates and numbers
  • xpath_query has some limitations due to our xpath parser if the value contains mixed quotes (" and '), so I made sure to check for this.

I believe we can and should move away from xpath_query when we implement forms, as there is no equivalent filter available for FormES. I opted to use xpath_query, even with its limitations, because it was the fastest way forward to a usable feature for most scenarios if we're just dealing with case data.

Additionally, I added utilities to BulkEditSession to:

  • add column filters
  • reorder column filters
  • and retrieve a filtered query set

We then use the filtered query set from the session in CleanCasesTableView.

Feature Flag

DATA_CLEANING_CASES

Safety Assurance

Safety story

safe. everything here is feature flagged and not part of production workflows

Automated test coverage

Yes, and lots of new tests added.

QA Plan

Not needed at this point

Migrations

  • The migrations in this code can be safely applied first independently of the code

Rollback instructions

  • This PR can be reverted after deploy with no further considerations

Labels & Review

  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

instead, CaseSearchES supports the concept of empty (both '' and unset values)
and missing (unset values only). Update NULL, NOT_NULL to be missing, not missing
this will make determining any related operators more straightforward
additionally, CaseSearchES xpath_query does not support <, >, <=, >= comparitors for text...only date and number
applies to match_types that are not in FilterMatchTypes.ALL_DATA_TYPES_CHOICES
this makes reordering easier (as we just need to pass in reordered list of UUIDs to update the index)
Additionally, it is more secure than just passing the pk, as that shows how many BulkEditColumns are available in the db.
- column_id to BulkEditColumn
- filter_id to BulkEditColumnFilter
- updates to FilterMatchType choices
@biyeun biyeun added the product/feature-flag Change will only affect users who have a specific feature flag enabled label Feb 25, 2025
@dimagimon dimagimon added the reindex/migration Reindex or migration will be required during or before deploy label Feb 25, 2025
Copy link
Contributor

@nospame nospame left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel like I have a full understanding of how this will be used, but the code all looks good to me. Couple nitpicks, with the note on UnsupportedFilterValueException as the only one I'd for sure like to see fixed before approving.

@biyeun biyeun merged commit 0d0b5f9 into master Feb 26, 2025
13 of 14 checks passed
@biyeun biyeun deleted the bmb/dc/filtering branch February 26, 2025 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product/feature-flag Change will only affect users who have a specific feature flag enabled reindex/migration Reindex or migration will be required during or before deploy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants